/**
 * (c) Copyright Ascensio System SIA 2025
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.zzvcom.office;

import com.zzvcom.office.documentserver.serializers.FilterState;
import com.zzvcom.office.entities.Close;
import com.zzvcom.office.entities.Goback;
import com.zzvcom.office.services.UserServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import jakarta.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

/**
 * 初始化示例用户数据的组件类。
 * 在Spring容器初始化完成后，自动创建一组预定义的用户数据用于演示或测试。
 */
@Component
public class ExampleData {
    @Autowired
    private UserServices userService;

    /**
     * Spring容器初始化完成后执行的方法。
     * 此方法用于初始化示例用户数据，包括不同权限和分组的多个用户。
     * 每个用户具有不同的描述信息、所属分组、过滤状态以及特定功能权限。
     */
    @PostConstruct
    public void init(){
        //initPost();
    }
    public void initPost() {
        // 定义用户0的描述信息：匿名用户，权限最低
        List<String> descriptionUserZero = List.of(
                "The name is requested when the editor is opened",     // 打开编辑器时需要输入姓名
                "Doesn’t belong to any group",                        // 不属于任何组
                "Can review all the changes",                         // 可以审阅所有更改
                "Can perform all actions with comments",              // 可以对评论执行所有操作
                "The file favorite state is undefined",               // 文件收藏状态未定义
                "Can't mention others in comments",                   // 不能在评论中提及他人
                "Can't create new files from the editor",             // 无法从编辑器创建新文件
                "Can’t see anyone’s information",                     // 无法查看任何用户的信息
                "Can't rename files from the editor",                 // 无法从编辑器重命名文件
                "Can't view chat",                                    // 无法查看聊天
                "Can't protect file",                                 // 无法保护文件
                "View file without collaboration",                    // 无协作查看文件
                "Can’t submit forms",                                 // 无法提交表单
                "Can't refresh outdated file"                         // 无法刷新过期文件
        );

        // 定义用户1的描述信息：默认文件作者，拥有较高权限
        // the description for user 1
        //这是用户1（John Smith）的权限描述列表，该用户是默认的文件作者，拥有最高的权限级别，包括：
        //不属于任何特定用户组
        //可以审阅所有用户的更改
        //可以管理所有评论
        //可以查看所有用户信息
        //可以使用聊天功能
        //拥有头像
        //可以提交表单等高级功能
        List<String> descriptionUserFirst = List.of(
                "File author by default",                    // 默认文件作者
                "He doesn't belong to any of the groups",    // 不属于任何组
                "He can review all the changes",             // 可以审阅所有更改
                "He can do everything with the comments",     // 可以对评论执行所有操作
                "The file favorite state is undefined",      // 文件收藏状态未定义
                "Can create a file from a template with data from the editor",  // 可以从模板创建带有编辑器数据的文件
                "Can see the information about all users",   // 可以查看所有用户的信息
                "Can view chat",                             // 可以查看聊天
                "Has an avatar",                             // 拥有头像
                "Can submit forms"                           // 可以提交表单

        );
        // 定义用户2的描述信息：属于Group2，部分受限权限
        // the description for user 2
        List<String> descriptionUserSecond = List.of(
                "He belongs to Group2",                    // 他属于Group2
                "He can review only his own changes or the changes made by the users who don't belong"
                        + " to any of the groups",         // 他只能审阅自己的更改或不属于任何组的用户所做的更改
                "He can view every comment, edit his comments and the comments left by the users "
                        + "who don't belong to any of the groups and remove only his comments",
                // 他可以查看所有评论，编辑自己的评论和不属于任何组的用户留下的评论，但只能删除自己的评论
                "This file is favorite",               // 这个文件是收藏的
                "Can create a file from an editor",    // 可以从编辑器创建文件
                "Can see the information about users from Group2 and users who don't belong to any group",
                // 可以查看Group2用户和不属于任何组的用户的信息
                "Can view chat",                       // 可以查看聊天
                "Has an avatar",                       // 拥有头像
                "Can't submit forms"                   // 无法提交表单
        );

        // the description for user 3
        // 定义用户3的描述信息：属于Group3，更多限制权限
        List<String> descriptionUserThird = List.of(
                "He belongs to Group3",
                "He can review only the changes made by the users from Group2",
                "He can view the comments left by the users from Group2 and Group3 and edit the comments left by "
                        + "the users from Group2",
                "This file isn’t favorite",
                "He can’t copy data from the file into the clipboard",
                "He can’t download the file",
                "He can’t print the file",
                "Can create a file from an editor",
                "Can see the information about Group2 users",
                "Can view chat",
                "Can’t submit forms",
                "Can't close history",
                "Can't restore the file version"
        );

        // create user 1 with the specified parameters
        userService.createUser("John Smith", "smith@example.com",
                descriptionUserFirst,
                "",
                List.of(FilterState.NULL.toString()),
                List.of(FilterState.NULL.toString()),
                List.of(FilterState.NULL.toString()),
                List.of(FilterState.NULL.toString()),
                List.of(FilterState.NULL.toString()),
                null,
                true,
                true,
                true,
                new Goback("打开文件，blank false", false),
                new Close(null, false),
                true);

        // create user 2 with the specified parameters
        userService.createUser("Mark Pottato",
                "pottato@example.com", descriptionUserSecond,
                "group-2",
                List.of("", "group-2"),
                List.of(FilterState.NULL.toString()),
                List.of("group-2", ""),
                List.of("group-2"),
                List.of("group-2", ""),
                true,
                true,
                true, true,
                new Goback("打开文件,blank true", true), new Close(null, true), false);

        // create user 3 with the specified parameters
        userService.createUser("Hamish Mitchell",
                null, descriptionUserThird,
                "group-3",
                List.of("group-2"),
                List.of("group-2", "group-3"),
                List.of("group-2"),
                new ArrayList<>(),
                List.of("group-2"),
                false,
                true,
                true,
                false,
                null,
                new Close(null, true),
                false);

        // create user 0 with the specified parameters
        userService.createUser("Anonymous", null,
                descriptionUserZero, "",
                List.of(FilterState.NULL.toString()),
                List.of(FilterState.NULL.toString()),
                List.of(FilterState.NULL.toString()),
                List.of(FilterState.NULL.toString()),
                new ArrayList<>(), null,
                false,
                false,
                false,
                null,
                null,
                false);
    }
}
